project(vvxfconfd)
#AM_CPPFLAGS = \
#	-I$(top_srcdir) \
#	-DG_LOG_DOMAIN=\"xfconfd\" \
#	-DLIBXFCONF_COMPILATION \
#	-DBINDIR=\"$(bindir)\" \
#	-DLOCALEDIR=\"$(localedir)\" \
#	$(PLATFORM_CPPFLAGS)
#
#xfconfddir = $(HELPER_PATH_PREFIX)/xfce4/xfconf
#xfconfd_PROGRAMS = xfconfd

add_library(xfconfd-macros-interface
        INTERFACE
)

target_compile_definitions(xfconfd-macros-interface
        INTERFACE
        PACKAGE="${PROJECT_NAME}"
        VERSION="${PROJECT_VERSION}"
        # PACKAGE_VERSION="${PROJECT_VERSION}"
        # ICEAUTH_CMD="${ICEAUTH_CMD}"
        # REVISION="${PROJECT_VERSION}"
        # DATADIR="${CMAKE_INSTALL_DATADIR}"
        # SYSCONFDIR="${CMAKE_INSTALL_SYSCONFDIR}"
        # GETTEXT_PACKAGE="${PROJECT_NAME}"
        LOCALEDIR="${CMAKE_INSTALL_PREFIX}/share/locale"
        # PACKAGE_NAME="${PACKAGE}"
        # HELPERDIR="${CMAKE_INSTALL_PREFIX}/lib" #default
        # PACKAGE_DATADIR="${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}"
        # G_LOG_DOMAIN="${PROJECT_NAME}"
        # XFSM_SHUTDOWN_HELPER_CMD="${HELPER_PATH_PREFIX}/xfce4/session/xfsm-shutdown-helper"
        # DBUS_API_SUBJECT_TO_CHANGE
        # WNCK_I_KNOW_THIS_IS_UNSTABLE
        # UPOWER_ENABLE_DEPRECATED
        # PACKAGE_BUGREPORT="https://gitlab.xfce.org/xfce/xfce4-session"
)


#
set(xfconf_backend_sources )
#
#if BUILD_XFCONF_BACKEND_PERCHANNEL_XML
set(xfconf_backend_sources ${xfconf_backend_sources}
        xfconf-backend-perchannel-xml.c
        xfconf-backend-perchannel-xml.h
)
#endif
#
set(xfconfd_SOURCES
        main.c
        xfconf-backend-factory.c
        xfconf-backend-factory.h
        xfconf-backend.c
        xfconf-backend.h
        xfconf-daemon.c
        xfconf-daemon.h
        xfconf-lifecycle-manager.c
        xfconf-lifecycle-manager.h
        xfconf-locking-utils.c
        xfconf-locking-utils.h
        ${xfconf_backend_sources}
)

add_executable(${PROJECT_NAME}
        ${xfconfd_SOURCES}
)

set(deps)
if (${IS_ALONE_COMPILE})
	list(APPEND deps )
	list(APPEND deps PkgConfig::GLIB)
        list(APPEND deps PkgConfig::GTHREAD)
        list(APPEND deps PkgConfig::GIO_UNIX)
	list(APPEND deps PkgConfig::XFCE4_UTIL)
else()
	list(APPEND deps glib-shared)
	list(APPEND deps libxfce4util-shared)
endif()

target_link_libraries(${PROJECT_NAME}
        PRIVATE
        common
        gvaluefuncs
        dbus
        xfconfd-macros-interface
	${deps}
)
target_include_directories(${PROJECT_NAME}
        PRIVATE
        .
)
install(TARGETS ${PROJECT_NAME}
        DESTINATION ${HELPER_PATH_PREFIX}/vvxfce4/vvxfconf
)
#
#if ENABLE_PROFILING
#xfconfd_CFLAGS += -pg
#endif
#

#servicedir = $(datadir)/dbus-1/services
#service_in_files = org.xfce.Xfconf.service.in
#service_DATA = $(service_in_files:org.xfce.%.service.in=@XFCONF_SERVICE_NAME_PREFIX@.%.service)
set(HELPERDIR ${CMAKE_INSTALL_PREFIX}/${HELPER_PATH_PREFIX})
configure_file(
        ${CMAKE_CURRENT_SOURCE_DIR}/org.vvxfce.Xfconf.service.in
        ${CMAKE_CURRENT_BINARY_DIR}/org.vvxfce.Xfconf.service
        @ONLY
)

install(FILES
        ${CMAKE_CURRENT_BINARY_DIR}/org.vvxfce.Xfconf.service
        DESTINATION /usr/share/dbus-1/services
)

#EXTRA_DIST = \
#	xfconf-backend-perchannel-xml.c \
#	xfconf-backend-perchannel-xml.h \
#	$(service_in_files)
#
## required for gtk-doc
#dist-hook: all
